﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using FtpCrawler;
using LuceneIndex;
using LuceneSearcher;

namespace ConsoleTest
{
    public class Program
    {
        static void Main(string[] args)
        {

            FtpConfig ftpConfig = new FtpConfig("192.168.11.9");
            ftpConfig.Path = "/";
            IFileProcessor dbOut = new DbStoreProcessor(ConfigurationManager.ConnectionStrings["connectionString"].ToString());
            MainCrawler crawler = new MainCrawler(dbOut,
                new List<FtpConfig>() { ftpConfig });

            DateTime startTime = DateTime.Now;

            crawler.GetFileListsFromHost(ftpConfig);
            Console.WriteLine("");

            DateTime endTime = DateTime.Now;
            Console.WriteLine("处理文件+目录数：{0}个，   总共耗时{1}。", dbOut.GetFilesCount(), (endTime - startTime));


            /*
            DbFtpIndexer indexer = new DbFtpIndexer(ConfigurationManager.ConnectionStrings["book"].ToString());
            indexer.Index();
            */

            /*
            MainSearcher searcher = new MainSearcher();
            DateTime startTime = DateTime.Now;
            DirectoryInfo indexDir = new DirectoryInfo("index");
            Console.WriteLine(searcher.Search(indexDir.FullName, "奥林匹克"));
            Console.WriteLine("查询完成，费时：{0}", DateTime.Now - startTime);
            */
        }
    }
}
